/**
 * 
 */
package com.wsd.sys;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.wsd.action.BaseAction;
import com.wsd.bean.Admin;
import com.wsd.util.SysUtil;

/**
 * 
 * @author 小e
 * action权限拦截器
 *
 */
public class AuthorityInterceptor extends AbstractInterceptor {

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
	 */
	@Override
	public String intercept(ActionInvocation action) throws Exception {
		Admin admin = SysUtil.currentAdmin();
		BaseAction baseAction = (BaseAction) action.getProxy().getAction();
		if(admin == null){
			//return "authorityError";
			System.out.println("权限验证失败");
			baseAction.setSuccess(false);
			baseAction.getResult().put("msg", "登录超时，请重新登录");
			return "ajax";
		}else{
			return action.invoke();
		}
	}

}
